<%@ page contentType="text/html;charset=UTF-8" pageEncoding="utf-8" language="java"%>
<%@ page import="com.CGFrame.tree.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.io.*"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%> 
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%
	String path=request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
 %>
<html:html>
<script type="text/javascript" src="tree/Bs_Tree.class.js"></script>
<script type="text/javascript" src="tree/Bs_TreeElement.class.js"></script>
<script type="text/javascript" src="tree/Bs_Array.class.js"></script>
<head>
		<META http-equiv=Content-Type content="text/html; charset=utf-8">
		<LINK href="../styles/sciencee.css"  type=text/css rel=stylesheet>
		<LINK href="xtree.css"  type=text/css rel=stylesheet>
		<style type="text/css"></style>
		<title>CGProject</title>
		<html:base/>
</head>
<script language="javascript">
	var total_array = new Array();
	var total_array1 = new Array();
	var total_array2 = new Array();
 	var a = new Array;
 	a[0] = new Array;
 	a[0]['caption']          = '<bean:write name="Tree" property="nodeName"/> ';
 	a[0]['target']           = "panel";
	a[0]['events']			 = new Array;
	a[0]['events']['onClickCaption'] =	"toProject('<bean:write name="Tree" property="nodeLink"/>');";
	var i=-1;
</script>	
	<logic:iterate id="element" name="Tree" property="childs"><!--1-->

<script language="javascript">
		i++;
		
		if(i==0)
		{
			a[0]['children']      = new Array;
		}
		a[0]['children'][i]         = new Array;
		a[0]['children'][i]['caption']  ='<bean:write name="element" property="nodeName"/> ';
		</script>
		<logic:equal name="element" property="nodeType" value="Elementgroup">
			<script language="javascript">
				a[0]['children'][i]['events'] = new Array;				
				a[0]['children'][i]['events']['onClickCaption'] = "toElementGroup('<bean:write name="element" property="nodeLink"/>');";
			</script>
		</logic:equal>
		<logic:equal name="element" property="nodeType" value="Shotgroup">
			<script language="javascript">
				a[0]['children'][i]['events'] = new Array;				
				a[0]['children'][i]['events']['onClickCaption'] = "toShotGroup('<bean:write name="element" property="nodeLink"/>');";
			</script>
		</logic:equal>

		<script language="javascript">

		var j=-1;
</script>
		<logic:notEmpty name="element" property="childs">
		<logic:iterate id="element1" name="element" property="childs"><!--2-->
<script language="javascript">
			j++;
			if(j==0)
			{
				a[0]['children'][i]['children']      = new Array;
			}
			a[0]['children'][i]['children'][j]      = new Array;
			a[0]['children'][i]['children'][j]['caption']  ='<bean:write name="element1" property="nodeName"/>';
			
			</script>
			<logic:equal name="element1" property="nodeType" value="Elementgroup">
				<script language="javascript">
					a[0]['children'][i]['children'][j]['events'] = new Array;
					a[0]['children'][i]['children'][j]['events']['onClickCaption'] = "toElementGroup('<bean:write name="element1" property="nodeLink"/>');";
				</script>
			</logic:equal>
			<logic:equal name="element" property="nodeType" value="Shotgroup">
				<script language="javascript">
					a[0]['children'][i]['children'][j]['events'] = new Array;				
					a[0]['children'][i]['children'][j]['events']['onClickCaption'] = "toShotGroup('<bean:write name="element1" property="nodeLink"/>');";
				</script>
			</logic:equal>
			<logic:equal name="element" property="nodeType" value="Shot">
				<script language="javascript">
					a[0]['children'][i]['children'][j]['events'] = new Array;				
					a[0]['children'][i]['children'][j]['events']['onClickCaption'] = "toShot('<bean:write name="element1" property="nodeLink"/>');";
				</script>
			</logic:equal>
			<logic:equal name="element" property="nodeType" value="Element">
				<script language="javascript">
					a[0]['children'][i]['children'][j]['events'] = new Array;				
					a[0]['children'][i]['children'][j]['events']['onClickCaption'] = "toElement('<bean:write name="element1" property="nodeLink"/>');";
				</script>
			</logic:equal>


	
			<script language="javascript">
			var k=-1;
</script>	
			<logic:empty name="element1" property="childs">
				<script language="javascript">total_array2.push(new Array('<bean:write name="Tree" property="nodeName"/> ','<bean:write name="element" property="nodeName"/> ','<bean:write name="element1" property="nodeName"/>'));</script>
				<script language="javascript"> a[0]['children'][i]['children'][j]['icon']="folderClosed.gif"</script>
			</logic:empty>
			<logic:notEmpty name="element1"  property="nodeFlag">
				
				<logic:equal name="element1" property="nodeFlag" value="1" >
				<script language="javascript"> a[0]['children'][i]['children'][j]['icon']="exclamation1.gif"</script>
				</logic:equal>
				<logic:equal name="element1" property="nodeFlag" value="0" >
				<script language="javascript"> a[0]['children'][i]['children'][j]['icon']="exclamation2.gif"</script>
				</logic:equal>
			</logic:notEmpty>
			
				
				
				<logic:notEmpty name="element1" property="childs">
				<logic:iterate id="element2" name="element1" property="childs"><!--3-->
<script language="javascript">
				k++;
				if(k==0)
				{
					a[0]['children'][i]['children'][j]['children']         = new Array;
				}
				a[0]['children'][i]['children'][j]['children'][k]      = new Array;
				a[0]['children'][i]['children'][j]['children'][k]['caption']  ='<bean:write name="element2" property="nodeName"/>';
				</script>
				<logic:equal name="element1" property="nodeType" value="Elementgroup">
					<script language="javascript">
						a[0]['children'][i]['children'][j]['children'][k]['events'] = new Array;
						a[0]['children'][i]['children'][j]['children'][k]['events']['onClickCaption'] = "toElementGroup('<bean:write name="element2" property="nodeLink"/>');";
					</script>
				</logic:equal>
				<logic:equal name="element" property="nodeType" value="Shotgroup">
					<script language="javascript">
						a[0]['children'][i]['children'][j]['children'][k]['events'] = new Array;				
						a[0]['children'][i]['children'][j]['children'][k]['events']['onClickCaption'] = "toShotGroup('<bean:write name="element2" property="nodeLink"/>');";
					</script>
				</logic:equal>
				<logic:equal name="element2" property="nodeType" value="Shot">
					<script language="javascript">
						a[0]['children'][i]['children'][j]['children'][k]['events'] = new Array;				
						a[0]['children'][i]['children'][j]['children'][k]['events']['onClickCaption'] = "toShot('<bean:write name="element2" property="nodeLink"/>');";
					</script>
				</logic:equal>
				<logic:equal name="element2" property="nodeType" value="Element">
					<script language="javascript">
						a[0]['children'][i]['children'][j]['children'][k]['events'] = new Array;				
						a[0]['children'][i]['children'][j]['children'][k]['events']['onClickCaption'] = "toElement('<bean:write name="element2" property="nodeLink"/>');";
					</script>
				</logic:equal>



				<script language="javascript">
	
				
				var l=-1;
</script>
				<logic:empty name="element2" property="childs">
					<script language="javascript"> a[0]['children'][i]['children'][j]['children'][k]['icon']="folderClosed.gif"</script>
					<script language="javascript">total_array2.push(new Array('<bean:write name="Tree" property="nodeName"/> ','<bean:write name="element" property="nodeName"/> ','<bean:write name="element1" property="nodeName"/>','<bean:write name="element2" property="nodeName"/>'));</script>
				</logic:empty>
				<logic:notEmpty name="element2"  property="nodeFlag">
				 		
					<logic:equal name="element2" property="nodeFlag" value="1" >
						<script language="javascript">a[0]['children'][i]['children'][j]['children'][k]['icon']="exclamation1.gif"</script>
					</logic:equal>
					<logic:equal name="element2" property="nodeFlag" value="0" >
						<script language="javascript">a[0]['children'][i]['children'][j]['children'][k]['icon']="exclamation2.gif"</script>
					</logic:equal>
				</logic:notEmpty>

			
					<logic:notEmpty name="element2" property="childs">
					<logic:iterate id="element3" name="element2" property="childs">
<script language="javascript">
					
					l++;
					if(l==0)
					{
						a[0]['children'][i]['children'][j]['children'][k]['children']         = new Array;
					}
					a[0]['children'][i]['children'][j]['children'][k]['children'][l]      = new Array;
					a[0]['children'][i]['children'][j]['children'][k]['children'][l]['caption']  ='<bean:write name="element3" property="nodeName"/>';
					</script>
					<logic:equal name="element3" property="nodeType" value="Shot">
						<script language="javascript">
							a[0]['children'][i]['children'][j]['children'][k]['children'][l]['events'] = new Array;				
							a[0]['children'][i]['children'][j]['children'][k]['children'][l]['events']['onClickCaption'] = "toShot('<bean:write name="element3" property="nodeLink"/>');";
						</script>
					</logic:equal>
					<logic:equal name="element3" property="nodeType" value="Element">
						<script language="javascript">
							a[0]['children'][i]['children'][j]['children'][k]['children'][l]['events'] = new Array;				
							a[0]['children'][i]['children'][j]['children'][k]['children'][l]['events']['onClickCaption'] = "toElement('<bean:write name="element3" property="nodeLink"/>');";
						</script>
					</logic:equal>

	
					
					<script language="javascript">

					var m=-1;

</script>

					<logic:empty name="element3" property="childs">
						<script language="javascript">total_array2.push(new Array('<bean:write name="Tree" property="nodeName"/> ','<bean:write name="element" property="nodeName"/> ','<bean:write name="element1" property="nodeName"/>','<bean:write name="element2" property="nodeName"/>','<bean:write name="element3" property="nodeName"/>'));</script>
						<script language="javascript"> a[0]['children'][i]['children'][j]['children'][k]['children'][l]['icon']="folderClosed.gif"</script>
					</logic:empty>
					<logic:notEmpty name="element3"  property="nodeFlag">
						<logic:equal name="element3" property="nodeFlag" value="1" >
							<script language="javascript">a[0]['children'][i]['children'][j]['children'][k]['children'][l]['icon']="exclamation1.gif"</script>
						</logic:equal>
						<logic:equal name="element3" property="nodeFlag" value="0" >
							<script language="javascript">a[0]['children'][i]['children'][j]['children'][k]['children'][l]['icon']="exclamation2.gif"</script>
						</logic:equal>
					
					</logic:notEmpty>


					

						<logic:notEmpty name="element3" property="childs"><!--//-->
						<logic:iterate id="element4" name="element3" property="childs">
<script language="javascript">
						m++;

						if(m==0)
						{
							a[0]['children'][i]['children'][j]['children'][k]['children'][l]['children']     = new Array;
						}
						a[0]['children'][i]['children'][j]['children'][k]['children'][l]['children'][m]      = new Array;
						a[0]['children'][i]['children'][j]['children'][k]['children'][l]['children'][m]['caption']  ='<bean:write name="element4" property="nodeName"/>';
						</script>
						<logic:equal name="element4" property="nodeType" value="Shot">
							<script language="javascript">
								a[0]['children'][i]['children'][j]['children'][k]['children'][l]['children'][m]['events'] = new Array;				
								a[0]['children'][i]['children'][j]['children'][k]['children'][l]['children'][m]['events']['onClickCaption'] = "toShot('<bean:write name="element4" property="nodeLink"/>');";
							</script>
						</logic:equal>
						<logic:equal name="element4" property="nodeType" value="Element">
							<script language="javascript">
								a[0]['children'][i]['children'][j]['children'][k]['children'][l]['children'][m]['events'] = new Array;				
								a[0]['children'][i]['children'][j]['children'][k]['children'][l]['children'][m]['events']['onClickCaption'] = "toElement('<bean:write name="element4" property="nodeLink"/>');";
							</script>
						</logic:equal>

		
						
						<script language="javascript">

						var n=-1;
</script>
										
						<logic:empty name="element4" property="childs">
							<script language="javascript">total_array2.push(new Array('<bean:write name="Tree" property="nodeName"/> ','<bean:write name="element" property="nodeName"/> ','<bean:write name="element1" property="nodeName"/>','<bean:write name="element2" property="nodeName"/>','<bean:write name="element3" property="nodeName"/>','<bean:write name="element4" property="nodeName"/>'));</script>
							<script language="javascript"> a[0]['children'][i]['children'][j]['children'][k]['children'][l]['children'][m]['icon']="folderClosed.gif"</script>
						</logic:empty>
						<logic:notEmpty name="element4"  property="nodeFlag">
						
							<logic:equal name="element4" property="nodeFlag" value="1" >
								<script language="javascript">a[0]['children'][i]['children'][j]['children'][k]['children'][l]['children'][m]['icon']="exclamation1.gif"</script>
							</logic:equal>
							<logic:equal name="element4" property="nodeFlag" value="0" >
								<script language="javascript">a[0]['children'][i]['children'][j]['children'][k]['children'][l]['children'][m]['icon']="exclamation2.gif"</script>
							</logic:equal>							
						</logic:notEmpty>

			

	
						</logic:iterate>
						</logic:notEmpty>
				</logic:iterate><!--4-->
				</logic:notEmpty>
			</logic:iterate><!--3-->	
			</logic:notEmpty>



		
		</logic:iterate><!--2-->
		</logic:notEmpty>
	
	</logic:iterate><!--1-->
	
<script language="javascript">
  var tree = new Bs_Tree();
function init() {
  //tree = new Bs_Tree();
  tree.lookAhead = 2;
  tree.imageDir = 'win98/';
  tree.initByArray(a);
  tree.drawInto('treeDiv1');
  //test2()是打开目录,这里可以用来设置默认是否打开目录
//  setTimeout("test2()",1000);
}
function test()
{
	var i=0;
	for(i=0;i<total_array.length;i++)
	{
		tree.openPath(total_array[i],'caption')	
	}

}

function toProject(value)
{
	if(navigator.appName=="Microsoft Internet Explorer")
	{
		top.B.location.href="frame.do?Frame=12&Id="+getBID( )+"&"+value;
		top.D.location.href="frame.do?Frame=13&Id="+getDID( )+"&"+value;
	}
	else
	{
		value = value.replace(/&amp\;/g,"&");
		top.B.location.href="../frame.do?Frame=12&Id="+getBID( )+"&"+value;
		top.D.location.href="../frame.do?Frame=13&Id="+getDID( )+"&"+value;
	}
}

function toElementGroup(value)
{	if(navigator.appName=="Microsoft Internet Explorer")
	{
		top.B.location.href="frame.do?Frame=12&Id="+getBID( )+"&"+value;
		top.D.location.href="frame.do?Frame=13&Id="+getDID( )+"&"+value;
	}
	else
	{
		value = value.replace(/&amp\;/g,"&");
		top.B.location.href="../frame.do?Frame=12&Id="+getBID( )+"&"+value;
		top.D.location.href="../frame.do?Frame=13&Id="+getDID( )+"&"+value;
	}
}
function toShotGroup(value)
{
	if(navigator.appName=="Microsoft Internet Explorer")
	{
		top.B.location.href="frame.do?Frame=12&Id="+getBID( )+"&"+value;
		top.D.location.href="frame.do?Frame=13&Id="+getDID( )+"&"+value;
	}
	else
	{
		value = value.replace(/&amp\;/g,"&");
		top.B.location.href="../frame.do?Frame=12&Id="+getBID( )+"&"+value;
		top.D.location.href="../frame.do?Frame=13&Id="+getDID( )+"&"+value;
	}
}
function toShot(value)
{
	if(navigator.appName=="Microsoft Internet Explorer")
	{
		top.B.location.href="frame.do?Frame=12&Id="+getBID( )+"&"+value;
		top.D.location.href="frame.do?Frame=13&Id="+getDID( )+"&"+value;
		
	}
	else
	{
		value = value.replace(/&amp\;/g,"&");
		top.B.location.href="../frame.do?Frame=12&Id="+getBID( )+"&"+value;
		top.D.location.href="../frame.do?Frame=13&Id="+getDID( )+"&"+value;
		
	}
}
function toElement(value)
{
	if(navigator.appName=="Microsoft Internet Explorer")
	{
		top.B.location.href="frame.do?Frame=12&Id="+getBID( )+"&"+value;
		top.D.location.href="frame.do?Frame=13&Id="+getDID( )+"&"+value;
	}
	else
	{
		value = value.replace(/&amp\;/g,"&");
		top.B.location.href="../frame.do?Frame=12&Id="+getBID( )+"&"+value;
		top.D.location.href="../frame.do?Frame=13&Id="+getDID( )+"&"+value;
		
	}
}

 function getBID( ) {  
    
     var query = top.B.location.search.substring(1);     // Get query string  
     var pairs = query.split("&");                 // Break at ampersand  
     for(var i = 0; i < pairs.length; i++) {  
         var pos = pairs[i].indexOf('=');          // Look for "name=value"  
         if (pos == -1) continue;                  // If not found, skip  
         var argname = pairs[i].substring(0,pos);  // Extract the name  
         var value = pairs[i].substring(pos+1);    // Extract the value  
         value = decodeURIComponent(value);        // Decode it, if needed  
         if (argname=="Id")                        // Choose "Id"    
     		return value;
     }  
     return "16";                                    // Not exist ,return preview
 }
  function getDID( ) {  
    
     var query = top.D.location.search.substring(1);     // Get query string  
     var pairs = query.split("&");                 // Break at ampersand  
     for(var i = 0; i < pairs.length; i++) {  
         var pos = pairs[i].indexOf('=');          // Look for "name=value"  
         if (pos == -1) continue;                  // If not found, skip  
         var argname = pairs[i].substring(0,pos);  // Extract the name  
         var value = pairs[i].substring(pos+1);    // Extract the value  
         value = decodeURIComponent(value);        // Decode it, if needed  
         if (argname=="Id")                        // Choose "Id"
         {
         	if(value==10 || value==18)
         		break;
         	else
	     		return value;
     	 }
     }  
     return "19";                                    // Not exist ,return detail
 }


function test1()
{
	var i=0;
	for(i=0;i<total_array1.length;i++)
	{
		tree.openPath(total_array1[i],'caption')	
	}

}

function test2()
{
	for(var xx=0;xx<total_array2.length;xx++)
	{

		//alert(total_array2[xx].toString());
		tree.openPath(total_array2[xx],'caption');
	}
}

</script>	
<body onLoad="init();">
<table border="0" width="100%" id="table1"  >
	
		
	</table>
<table border="0" width="100%" >
	<tr>
		<td id="treeDiv1">

		</td>
	</tr>

</body>
</html:html>	

